<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>学生管理系统</title>
  <link rel="stylesheet" href="${ssy}/resources/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">学生管理系统</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img id="userImg" src="${ssy}/resources/images/default.jpg"  class="layui-nav-img">
        	${user.uname}
        </a>
        <dl class="layui-nav-child">
          <dd><a id="updatePwd" href="#">修改密码</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item"><a href="${ssy}/user.do?type=exit">退出</a></li>
    </ul>
  </div>

  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test">
        <c:if test="${user.uType == 2 }">
          <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">信息查询</a>
          <dl class="layui-nav-child">
            <dd><a href="${ssy}/page.do?type=studentInfo" target="content">学生及班级信息</a></dd>
            <dd><a href="${ssy}/page.do?type=curriculumInfo" target="content">课程表信息</a></dd>
            <dd><a href="${ssy}/page.do?type=scoreInfo" target="content">成绩信息</a></dd>
          </dl>
        </li>
        </c:if>
        <c:if test="${user.uType == 1 }">
          <li class="layui-nav-item">
            <a class="" href="javascript:;">系统管理</a>
            <dl class="layui-nav-child">
              <dd><a href="${ssy}/page.do?type=userList" target="content">用户管理</a></dd>
              <dd><a href="${ssy}/page.do?type=studentList" target="content">学生管理</a></dd>
              <dd><a href="${ssy}/page.do?type=classList" target="content">班级管理</a></dd>
              <dd><a href="${ssy}/page.do?type=courseList" target="content">课程管理</a></dd>
              <dd><a href="${ssy}/page.do?type=curriculumList" target="content">课程表管理</a></dd>
              <dd><a href="${ssy}/page.do?type=scoreList" target="content">成绩管理</a></dd>
            </dl>
          </li>
        </c:if>
      </ul>
    </div>
  </div>

  <div class="layui-body">
    <!-- 内容主体区域 -->
    <iframe style="padding: 15px;width: 100%;height: 100%;border: 0px" name="content"  src="http://nows.fun/"></iframe>
  </div>

  <div class="layui-footer" style="text-align: center">
    <!-- 底部固定区域 -->
    ©copyright 2020 ssy-020321752323
  </div>
</div>

<script type="text/html" id="modifyData">
  <form class="layui-form layui-form-pane" lay-filter="dataFormFilter" id="searchForm" style="margin-top: 10px;margin-left:5px;">
    <div class="layui-col-md12 layui-col-xs12">
      <div class="layui-form-item" style="text-align: center;">
        <div class="layui-inline">
          <label class="layui-form-label">当前密码:</label>
          <div class="layui-input-inline">
            <input class="layui-input" type="password" name="password" lay-verify="required" placeholder="请输入当前密码">
          </div>
        </div>
      </div>
      <div class="layui-form-item" style="text-align: center;">
        <div class="layui-inline">
          <label class="layui-form-label">新密码:</label>
          <div class="layui-input-inline">
            <input class="layui-input" type="password" name="newPassword1" lay-verify="required" placeholder="请输入新密码">
          </div>
        </div>
      </div>
      <div class="layui-form-item" style="text-align: center;">
        <div class="layui-inline">
          <label class="layui-form-label">确认密码:</label>
          <div class="layui-input-inline">
            <input class="layui-input" type="password" name="newPassword2" lay-verify="required" placeholder="请确认新密码">
          </div>
        </div>
      </div>
      <div class="layui-form-item" style="text-align: center;">
        <input type="hidden" lay-filter="subBtn" id="subBtn" lay-submit />
      </div>
    </div>
  </form>
</script>
<script src="${ssy}/resources/layui/layui.js"></script>
<script>
layui.use(['element','jquery','layer','form'], function(){
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    $("#updatePwd").click(function () {
      layer.open({
        type:1,
        content:$("#modifyData").html(),
        btn: ['确认', '取消'],
        area:['500px','340px'],
        btnAlign: 'c',
        title:'修改密码',
        success:function(layero, index){
          //为更新form 绑定提交事件
          form.on("submit(subBtn)",function(d){
            var data=d.field;
            //debugger;
            if(data.newPassword1!=data.newPassword2){
              layer.msg("两次密码不一致");
              return false;
            }

            $.post("${ssy}/user.do?type=updatePwd",data,function(rs){
              if(rs.code == 200){
                layer.msg("密码修改成功");
                layer.alert("密码修改成功，请重新登录",function(){
                  window.parent.location.href='${ssy}/user.do?type=exit';
                });
              }else {
                layer.msg(rs.msg);
              }

            });
            return false;
          });
        },
        yes:function(index){
          $("#subBtn").click();
        }
      });
  });
});
</script>
</body>
</html>